import { Component, OnInit, Input } from '@angular/core';
import { _HttpClient } from '@delon/theme';
import { environment } from '@env/environment';
import { DatePipe } from '@angular/common';
import { StatusFollowService } from '@core/statusFollow.service';
import { NzMessageService } from 'ng-zorro-antd';
@Component({
    selector: 'app-splc-wcqk',
    templateUrl: './splc_wcqk.component.html',
    styleUrls: ['./splc_wcqk.component.less']
})
export class SplcWcqkComponent implements OnInit {
    queryParam: any = {};
    tableData = []
    pageType: any;
    pageSize = '20';
    pageTotal = 0;
    pageIndex = 1;
    loading = false;
    mode = 'query';
    fontSize = '14px';
    lockHeadScroll = { y: window.innerHeight - 350 + 'px' };

    @Input() set params(param) {
        if (param.mode) {
            this.mode = param.mode;
        }
        if (param.pId) {
            this.queryParam.pid = param.pId;
            this.query();
        }
    };
    @Input() set sizeMode(v) {
        this.fontSize = v === 'max' ? '20px' : '14px';
    }

    constructor(
        private http: _HttpClient,
        public statusFollowService: StatusFollowService,
        public message: NzMessageService,
        private datePipe: DatePipe
    ) { }

    ngOnInit(): void { 
    }

    formatHref(data) {
        return environment.problem + data.fileUrl;
    }

    query(fromBeginning = false) {
        const param = {
            page: fromBeginning === false ? this.pageIndex : 1,
            limit: this.pageSize,
        };
        Object.assign(param, this.queryParam);
        // this.removePrivateFields(param);
        this.loading = true;
        this.query_detail(param).subscribe(res => {
            this.loading = false;
            this.tableData = res.data[0];
            this.pageTotal = res.count;
        });
    }




    lrsjChange(v, row) {
        row.sysDate = this.datePipe.transform(v, 'yyyy-MM-dd HH:mm');
    }


    /**
     * 完成情况查询
     * @param pId 1 
     */
    query_detail(param) {
        const dataurl = environment.problem + '/auditProcessLog/query';
        return this.http.get(dataurl, param);
    }


}
